package net.wofly.sale.order.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.wofly.sale.activity.domain.ActivityGift;
import net.wofly.sale.commodity.domain.Commodity;
import net.wofly.sale.commodity.domain.CommodityTerminal;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * 订单内容
 *
 * @author lign
 * @version 1.0
 * @created 26-11月-2017 11:32:51
 */
@Data
@Entity
@Table(name = "sale_order_ordercontent")
@ApiModel(description = "订单内容")
public class OrderContent {
    
    @ApiModelProperty(value = "赠品（提交）")
    @OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
    @JoinColumn(name = "relateID")
    public List<Gift> gifts;
    
    @Transient
    @ApiModelProperty(value = "活动赠品（前端提交订单之前的赠品对象，给前端展示用）")
    private List<ActivityGift> activityGifts;
    
    @Id
    private String orderContentID;
    /**
     * 活动价
     * <ul>
     * <li>默认正常价与活动价是一样的</li>
     * <li>当活动有价格有优惠时，活动价与正常价有差异</li>
     * <li>计算结算价时，都是以最终活动价来计算</li>
     * </ul>
     */
    private Double activityPrice;
    /**
     * 活动总价
     */
    private Double activityTotalPrice;
    private String commodityChannelID;
    private Long modifyDate;
    
    @ApiModelProperty(value = "购买数量")
    private Integer num;
    
    @ApiModelProperty(value = "预购数量")
    private Integer preorderNum;
    
    private String orderID;
    /**
     * 对应的渠道价
     */
    private Double price;
    /**
     * 总价
     */
    private Double totalPrice;
    
    @ApiModelProperty(value = "商品详情， 查询时用")
    @Transient
    private Commodity commodity;
    
    @ApiModelProperty(value = "商品库存不足提示语")
    @Transient
    private String stockLackMsg;
    
    /**
     * 商品终端ID
     */
    private String commodityTerminalID;
    
    @Transient
    private CommodityTerminal commodityTerminal;
    
    public OrderContent() {
    
    }
    @Override
    public void finalize() throws Throwable {
    
    }
}